package com.perceptivesoftware.licensing.client.dialogs.useradmin.plugin.role;

import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.form.CheckBox;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.perceptivesoftware.licensing.client.dialogs.useradmin.SecurityManagerView;

public class RoleView extends SecurityManagerView {

	private final CheckBox cascadeCheckbox = new CheckBox();

	public RoleView(final ContentPanel permissionsController) {
		super();
		if (permissionsController == null) {
			initComponent(new LayoutContainer());
			return;
		}
		permissionsController.setHeaderVisible(false);
		permissionsController.setFooter(true);
		cascadeCheckbox.setBoxLabel("Apply changed (red) items to children on save");
		cascadeCheckbox.setValue(true);
		permissionsController.getButtonBar().setHeight(20);
		permissionsController.getButtonBar().add(cascadeCheckbox);
		permissionsController.setButtonAlign(HorizontalAlignment.CENTER);
		permissionsController.setLayout(new FitLayout());
		permissionsController.add(permissionsController);
		initComponent(permissionsController);
	}

	public Boolean getCascadeToChildrenChecked() {
		return cascadeCheckbox.getValue();
	}

	@Override
	public String getName() {
		return "Role Editor";
	}
}